<?php

$db = [
  'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=elaid',
    'username' => 'root',
    'password' => '123456',
    'charset' => 'utf8',
  ],
];

$config = [
  'basePath' => dirname(__DIR__),
  'bootstrap' => ['log', 'weixinhelper'],
  'defaultRoute' => 'demo',
  'modules' => [
    'weixinhelper' => [
      'class' => 'tengze\weixinhelper\Module'
    ],
    'cdnassets' => [
      'class' => 'tengze\cdnassets\Module'
    ]
  ],
  'components' => [
    'request' => [
        // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
        'cookieValidationKey' => 'Tengzhe@2016',
        'enableCookieValidation' => false,
        'enableCsrfValidation' => false,
    ],
    'memcache' => [
      'class' => 'yii\caching\MemCache',
      'servers' => [
          [
            'host' => '127.0.0.1',
            'port' => 11211,
            'weight' => 60,
          ],
      ],
    ],
    'redis' => [
      'class' => 'yii\redis\Connection',
      'hostname' => '10.251.7.42',
      'port' => 6380,
      'database' => 0,
    ],
    'wxcache' => [
      'class' => 'yii\caching\FileCache'
      // 'cachePath' => '@app/../cache'
    ],
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules'=>[
            'admin/<controller:\w+>/<action:\w+>'=>'admin/<controller>/<action>',    //general rule
        //'<module:\w+>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',    //general rule
        ],
    ],
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['trace', 'profile', 'info', 'error', 'warning'],
                'logFile' => '@app/runtime/logs/full.log',
            ],
            [
              'class' => 'yii\log\FileTarget',
              'categories' => ['kplog'],
              'levels' => ['error', 'warning', 'info'],
              'logFile' => '@app/runtime/logs/kplog.log',
            ],
        ],
    ],
    'db' => $db['db'],
  ],
];

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
